﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using ControleRepresentante.Logic.Models;
using WebSite.Controllers;
using WebSite.ViewModels.Fields;

namespace WebSite.ViewModels.DetailsViewModels
{
    public class VendedorDetailsViewModel : UsuariosHolderDetailsViewModel
    {
        private readonly Dictionary<string, double> m_Vendas;

        public VendedorDetailsViewModel(Dictionary<string, double> vendas) 
            : base("Vendedor")
        {
            m_Vendas = vendas;
        }

        protected override IEnumerable<IField> GetGeralFields()
        {
            Vendedor vendedor = (Vendedor) Model;
            List<IField> result = new List<IField>
            {
                new LabelField("Nome", "nome", vendedor.Nome),
                new LabelField("Nascimento", "nascimento", vendedor.Nascimento),
                new LabelField("CPF", "cpf", vendedor.CPF),
                new LabelField("Identidade", "identidade", vendedor.Identidade),
            };
            result.AddRange(base.GetGeralFields());
            return result;
        }

        protected override IEnumerable<TabItem> GetTabs(HtmlHelper htmlHelper)
        {
            List<TabItem> result = base.GetTabs(htmlHelper).ToList();

            ChartSeries chartSeries = new ChartSeries("Total em R$", m_Vendas);

            result.Add(new TabItem("Vendas",
                "~/Content/statistics.png",
                htmlHelper.GoogleBarChart("Ultimos 12 meses", chartSeries).ToHtmlString()));

            return result;
        }
    }
}